package com.hotel.Impl;

import java.util.List;

import com.hotel.dao.YgDao;
import com.hotel.entity.Staff;
import com.hotel.entity.Yhuser;
import com.hotel.util.DbBuilder;

public class YgDaoImpl implements YgDao {

	@Override
	public List<Staff> ygAll() {
		String sql="select * from staff ";
		return DbBuilder.getListBean(sql, Staff.class);
	}

	@Override
	public int addStaff(Staff staff) {
		String sql="insert into staff values(null,?,?,?,?,?,?)";
		return DbBuilder.update(sql, Staff.class,staff.getPosition(),staff.getEmpname(),staff.getEmpphone(),staff.getEmpsex(),staff.getEmpsfz(),staff.getEmptime());
	}

	@Override
	public Staff getStaffById(int id) {
		String sql="select * from staff where id=?";
		return DbBuilder.getBean(sql, Staff.class,id);
	}

	@Override
	public int updateYg(Staff staff) {
		String sql="update yhuser set empname=?,empphone=?,empsex=?,empsex=?,empsfz=?,position=?,emptime=?";
		return DbBuilder.update(sql, Staff.class,staff.getEmpname(),staff.getEmpphone(),staff.getEmpsex(),staff.getEmpsfz(),staff.getPosition(),staff.getEmptime());
	}

	@Override
	public int deleteStaff(int id) {
	String sql="delete form staff where id=?";
	return DbBuilder.delete(sql, Staff.class,id);
		
	}

}
